package com.atguigu.yygh.user.controller.admin;

import com.atguigu.yygh.model.user.UserInfo;
import com.atguigu.yygh.result.R;
import com.atguigu.yygh.user.service.UserInfoService;
import com.atguigu.yygh.vo.user.UserInfoQueryVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/3/23 1:39
 */
@RestController
@RequestMapping("/admin/userinfo")
public class UserController {
    @Autowired
    private UserInfoService userInfoService;

    //带查询条件的分页查询用户信息
    @GetMapping("/{page}/{limit}")
    public R userList(@PathVariable("page") Integer page
                , @PathVariable("limit") Integer limit
                , UserInfoQueryVo userInfoQueryVo) {
        Page<UserInfo> page1 =userInfoService.userListByCondition(page, limit,userInfoQueryVo);
        return R.ok().data("page", page1);
    }
    @PutMapping("lock/{userId}/{status}")
    public R lockUser(@PathVariable("userId") String userId, @PathVariable("status") Integer status){
        userInfoService.lockUser(userId,status);
        return R.ok();
    }
    @GetMapping("show/{userId}")
    public R showUser(@PathVariable("userId") Long userId){
        Map<String, Object> userMap =userInfoService.showUser(userId);
        return R.ok().data(userMap);
    }
    //认证审批
    @GetMapping("/approval/{id}/{authStatus}")
    public R approval(@PathVariable("id") Long id, @PathVariable("authStatus") Integer authStatus){
        userInfoService.approval(id,authStatus);
        return R.ok();
    }
}
